<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>
      <table border="1">
        <tr>
          <td>照片</td>
          <td><img :src="person.url" width="100" /></td>
        </tr>
        <tr>
          <td>名字：</td>
          <td>{{ person.name }}</td>
        </tr>
        <tr>
          <td>年龄：</td>
          <td>{{ person.age }}</td>
        </tr>
        <tr>
          <td>爱好：</td>
          <td>
            <ul>
              <li v-for="hobby in person.hobbies">{{ hobby }}</li>
            </ul>
          </td>
        </tr>
      </table>
      <input type="button" value="加载数据" @click="f()" />
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
      let app = new Vue({
        el: "body>div",
        data: {
          person: {
            name: "",
            age: "",
            url: "",
            hobbies: [],
          },
        },
        methods: {
          f() {
            app.person = {
              name: "蔡徐坤",
              url: "https://tse2-mm.cn.bing.net/th/id/OIP-C.gU9VLi5ON1b7x34NeQ20PgHaG5?w=203&h=189&c=7&r=0&o=5&dpr=1.5&pid=1.7",
              age: 24,
              hobbies: ["唱", "跳", "rap", "篮球"],
            };
          },
        },
      });
    </script>
  </body>
</html>
